{template 'header'}
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWeburl('rule');}">规则管理</a></li>
    <li class=""><a href="{php echo $this->createWeburl('rule', array('op' => 'addShow'));}">添加规则</a></li>
</ul>
<form action="" method="post" class="form-horizontal" id="myform" role="form" enctype="multipart/form-data">
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">标题<span style="color: red">*</span>:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="title" placeholder="标题" value="{$rule['title']}" type="text">
        </div>
    </div>
            <span id="cash_explain">
            {loop $rule['content'] $key $item}
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-1 control-label">{if $key == 0}内容:{/if}</label>
                <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
                    <input class="form-control" style="width:80%;float:left" name="content[]" placeholder="内容" value="{$item}" type="text">
                    {if $key == 0}
                    <button type="button" style="margin-left: 5px;" class="btn btn-primary" id="add_cash_explain">增加</button>
                    {else}
                    <button type="button" style="margin-left: 5px;" class="btn btn-primary" onclick="delete_cash_explain(this)">删除</button>
                    {/if}
                </div>
            </div>
            {/loop}
        </span>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">是否显示</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="position" value="1" {if $rule['position'] ==1 || $rule['position'] == ''} checked {/if} /> 活动规则
            </label>
            <label class="radio-inline">
                <input type="radio" name="position" value="2" {if $rule['position'] ==2} checked {/if}/>常见问题
            </label>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">序号:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="sort" placeholder="序号" value="{$rule['sort']}" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label"></label>
        <div class="" >
            <input type="hidden" name="op" value="{php echo $id ? 'edit' : 'add'}">
            <input type="hidden" name="id" value="{$id}">
            <input type="submit" name="submit" id="submit" value="{php echo $id ? '修改' : '新增'}" class="btn btn-primary">
        </div>
    </div>
</form>
{template 'footer'}

<script type="application/javascript">
    $(function () {
        $('#add_cash_explain').click(function () {
            var html = '<div class="form-group">' +
                '<label class="col-xs-12 col-sm-3 col-md-1 control-label"></label>' +
                '<div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">' +
                '<input class="form-control" style="width:80%;float:left" name="content[]" placeholder="内容" value="" type="text">' +
                '<button type="button" style="margin-left: 5px;" class="btn btn-primary" onclick="delete_cash_explain(this)">删除</button>' +
                '</div>' +
                '</div>';
            $('#cash_explain').append(html);
        });
    });
    function delete_cash_explain(t) {
        $(t).parent().parent().remove();
    }
</script>